package com.cn.ysf.newbeemall;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.ApplicationContext;

import java.net.InetAddress;
import java.net.UnknownHostException;


@MapperScan("com.cn.ysf.newbeemall.mapper")
@SpringBootApplication
public class NewbeemallApplication {

    private static ApplicationContext ctx;

    public static void main(String[] args) {
        ctx =SpringApplication.run(NewbeemallApplication.class, args);
        try {
            String host= InetAddress.getLocalHost().getHostAddress();
            TomcatServletWebServerFactory tomcatServletWebServerFactory=(TomcatServletWebServerFactory) ctx.getBean("tomcatServletWebServerFactory");
            int port=tomcatServletWebServerFactory.getPort();
            String contextPath=tomcatServletWebServerFactory.getContextPath();
            System.out.println("http://localhost:"+port+contextPath+"/");
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }

}
